#pragma once    
#include <QWidget>
#include <QLabel>
#include <QScrollArea>

enum ItemType 
{
    SessionItemType,
    FriendItemType,
    ApplyItemType
};

class SessionFriendArea : public QScrollArea
{
    Q_OBJECT
public:
    explicit SessionFriendArea(QWidget* parent);
    void clear();
    void addItem(ItemType itemType,const QString& id, const QIcon& avatar, const QString& name, const QString& text);
    void clickItem(int index);
signals:

private:
    // 后续往 container 内部的 layout 中添加元素, 就能够触发 QScrollArea 滚动效果.
    // container高度会变化
    QWidget* container;
};


class SessionFriendItem:public QWidget
{
    Q_OBJECT
public:
    SessionFriendItem(QWidget* owner, const QIcon& avatar, const QString& name, const QString& text);
    void paintEvent(QPaintEvent* event) override;
    void mousePressEvent(QMouseEvent* event)override;
    void enterEvent(QEnterEvent* event)override;
    void leaveEvent(QEvent* event)override;
    void select();
    void virtual active();
protected:
    QLabel* messageLabel;
private:
    QWidget* owner;
    bool selected = false;
};

//会话item的的实现
class SessionItem :public SessionFriendItem 
{
    Q_OBJECT
public:
    SessionItem(QWidget* owner, const QString& chatSessionId, const QIcon& avatar, const QString& name, const QString& lastMessage);
    void active() override;
private:
    QString chatSessionId;
};

//好友item的实现
class FriendItem :public SessionFriendItem 
{
    Q_OBJECT
public:
    FriendItem(QWidget* owner, const QString& userId, const QIcon& avatar, const QString& name, const QString& description);
    void active() override;
private:
    QString userId;
};

//好友申请item的实现
class ApplyItem :public SessionFriendItem
{
    Q_OBJECT
public:
    ApplyItem(QWidget* owner, const QString& userId, const QIcon& avatar, const QString& name);
    void active() override;
private:
    QString userId;
};